{% extends "_layout.html" %}
{% import "component/statistics.njk" as statistics %}

{# 样式代码 #}
{% block style %}
<title>一对一出题-选择学生</title>
<style type="text/css">
    .mui-table-view-cell{ line-height: 44px;}
    .mui-content>.mui-table-view:first-child{ margin-top: 0;}
</style>
{% endblock %}

{# bodyd代码#}
{% block body %}
<div class="mui-content">
    <!--单选题-->
    {% for item in data %}
        <div class="mui-card">
            <div class="mui-input-row mui-checkbox">
                <label>{{item.name}}</label>
                <input name="checkbox1" data-id="{{item.id}}" type="checkbox" onclick="js_on(this)">
            </div>
        </div>
    {%endfor%}
</div>

<nav class="mui-bar mui-bar-tab mb-subject-tab">
    <a class="mui-tab-item1" href="javascript:void(0)" onclick="js_tj()">
        <span class="mui-tab-label">去发布（<span id="number">0</span>）</span>
    </a>
</nav>
{% endblock %}

{#js代码#}
{% block js %}

<script>



    var arr = [];
    var n = 0;

    function js_on(e){
        arr.push($(e).data('id'));
        $('#number').text(++n);
        $(e).attr('onclick','js_off(this)');
        console.log(arr);
    }

    function js_off(e){
        $('#number').text(--n);
        for(let i=0;i<arr.length;i++){
            if(arr[i] == $(e).data('id')){
                arr.splice(i,1);
                break;
            }
        }
        console.log(arr);
        $(e).attr('onclick','js_on(this)');
    }

    function js_tj(){
        let id = sessionStorage.getItem('tzid');
        sessionStorage.removeItem('tzid');
        sessionStorage.setItem('studentIds',arr);
        window.location.replace("/arrhomework2?id="+id);
    }
</script>

<!--flotdemo-->
{% endblock %}
